package top.ashman.demo.springcloud.hystrix.command;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import top.ashman.demo.springcloud.hystrix.MyUtil;

/**
 * 用于以 Hystrix 的方式执行请求
 *
 * @author sunzhaojie
 * @date 2018-12-10
 */
public class MyCommand extends HystrixCommand<String> {

    MyCommand() {
        super(HystrixCommandGroupKey.Factory.asKey("myGroup"));
    }

    @Override
    protected String run() throws Exception {
        var response = MyUtil.request("http://localhost:8765/my/hello");
        MyUtil.printResponse(response);
        return response.body();
    }
}
